<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="header.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<form id="formId" method="post">
		用户名: <input type="text" name="name"/><br/>
		密码: <input type="password" name="password"/><br/>
		邮箱: <input type="text" name="email"/><br/>
		年龄: <input type="text" name="age"/><br/>
		部门: <select name="departmentId">
				<c:forEach items="${list}" var="department">
					<option value="${department.id}">${department.name}</option>
				</c:forEach>
			</select>
			<br/>
		 <input type="button" onclick="submitForm()" value="添加"/><br/>
	</form>
	
	<script type="text/javascript">
		function submitForm() {
			$.post('${path}/user?method=insert',
					$('#formId').serialize(),
					function(jsonResult) {
						if(jsonResult.code == 0) {
							mylayer.okUrl(jsonResult.msg, '${path}/user?method=selectByPage');
						} else {
							mylayer.errorMsg(jsonResult.msg);
						}
				    },
				    'json');
		}
	</script>
	
</body>
</html>